<template>
  <div></div>
</template>

<script lang="ts" setup>
  import { useRouter, useRoute } from 'vue-router';

  const router = useRouter();
  const route = useRoute();

  const parseUrlParams = (url:string) => {
    const queryString = url.split('?')[1];
    if (!queryString) return {}; // 如果没有参数，返回空对象
    return queryString.split('&').reduce((params:any, param) => {
      const [key, value] = param.split('=');
      params[key] = decodeURIComponent(value); // 解码参数值
      return params;
    }, {});
  }

  const urlBase = (url:string) => {
    return url.split('?')[0];
  }

  console.log(route)
  console.log(router)
  console.log('222222222')
  const gotoPath = route.params.path as string;
  const query = parseUrlParams(gotoPath);
  console.log(query)
  router.currentRoute.value.query = parseUrlParams(gotoPath)
  router.replace({ path: urlBase(gotoPath) });


</script>

<style scoped lang="less"></style>
